package com.dmz.task.config;

import com.dmz.common.utils.secure.GMUtil;
import com.zaxxer.hikari.HikariDataSource;

/**
 * @author lee
 */
public class MyHikariDataSource extends HikariDataSource {

    private String key = EnvConfig.getProperty("sm4.key");

    private String iv = EnvConfig.getProperty("sm4.iv");

    @Override
    public String getUsername() {
        // 对用户名进行解密
        try {
            return GMUtil.db(key, iv, super.getUsername().substring(4,28));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public String getPassword() {
        // 对密码进行解密
        try {
            return GMUtil.db(key, iv, super.getPassword().substring(4,28));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
